<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // ES5
        var studentES5 = {
            name: '小方哥',
            age: 20,
            sex: '男',
            getName: function () {
                return this.name;
            }
        }
        console.log('ES5', studentES5);
        console.log('ES5', studentES5.getName());
        console.log("============================================")
        // ES6
        const name = 'Jack';
        const age = 25;
        const sex = '女';
        const studentES6 = {
            name,// 同名的属性可以省略不写
            age,
            sex,
            getName() {// 可以省略方法中的 : function
                return this.name;
            }
        };
        console.log('ES6', studentES6);
        console.log('ES6', studentES6.getName());
    </script>

</body>

</html>